<%-- 
    Document   : listReservation
    Created on : 20 juil. 2013, 17:31:35
    Author     : Jawad
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="ws.*, java.util.List" %>
<%! List<TypeChambre> resultType;%>
<%! List<Chambre> resultChambreByType;%>
<%! int typeChambre = 1;%>
<%    
    resultType = (List<TypeChambre>) session.getAttribute("typeChambre");
    try {
        WebServiceHotelService service = new WebServiceHotelService();
        WebServiceHotel port = service.getWebServiceHotelPort();
        if (request.getParameter("action") != null && request.getParameter("action").equals("ok")) {
            typeChambre = Integer.parseInt(request.getParameter("typechambre"));
        }
        resultChambreByType = port.listeChambreByType(typeChambre);
    } catch (Exception ex) {
        out.println(ex);
    }

%>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Hotel MIAGE</title>
    </head>
    <body>
        <h1>Liste de nos chambres</h1>
        <b>Capacité de couchage:</b>
        <form action="listReservation.jsp" method="get">
            <select name="typechambre">
                <% for (TypeChambre t : resultType) {%>
                <option value="<%= t.getId()%>" 
                        <%if (t.getId() == typeChambre) {%>
                        selected="selected"
                        <% }%> >
                    <%= t.getTypeChambre()%>
                </option>
                <% }%>
            </select>
            <input type="submit" name="action" value="ok">
        </form>
        <table border="1">
            <tr>
                <th>Numéro chambre</th><th>Etat</th>
            </tr>
            <% for (Chambre b : resultChambreByType) {%>
            <tr>
                <td><%= b.getId()%></td><td style="background: <% if (b.isDisp()) {
                        out.print("green");
                    } else {
                        out.print("red");
                    }%>" />
                <% if (b.isDisp()) {
                        out.print("<td> <a href=addReservation.jsp?idchambre=" + b.getId() + ">Réserver</a> </td>");
                    }
                %>
            </tr>
            <% }%>
        </table>
    </body>
</html>
